import fetch from 'utils/fetch'

export default { // 赛事接口
  // 发起、编辑球类赛事
  release (data = {}, options) {
    if (data) {
      data.matchChannelsList = JSON.stringify(data.matchChannelsList)
    }
    return fetch({
      url: '/match/save',
      method: 'post',
      options,
      data
    })
  },
  // 发起、编辑跑步赛事
  releaseRun (data = {}, options) {
    if (data) {
      data.matchChannelsList = JSON.stringify(data.matchChannelsList)
    }
    return fetch({
      url: '/match/run/save',
      method: 'post',
      options,
      data
    })
  },
  list (params) {
    return fetch({
      url: '/match/select/list',
      params: params
    })
  },
  // 赛事详情
  detail (params) {
    return fetch({
      url: '/match/details',
      params: params
    })
  },
  // 跑步详情
  runDetail (params) {
    return fetch({
      url: '/match/run/details',
      params: params
    })
  },
  // 获取跑步赛事要求信息
  runRequirement (params) {
    return fetch({
      url: '/match/run/requirement',
      params: params
    })
  },
  // 获取球类赛事要求信息
  requirement (params) {
    return fetch({
      url: '/match/requirement',
      params: params
    })
  },
  // 保存赛事草稿
  draft (data, options) {
    if (data) {
      data.matchChannelsList = JSON.stringify(data.matchChannelsList)
    }
    return fetch({
      url: '/match/draft',
      method: 'post',
      data,
      options
    })
  },
  // 获取赛事草稿信息
  getDraft (params) {
    return fetch({
      url: '/match/get/draftInfo',
      params: params
    })
  },
  // 获取赛制下面的具体赛制信息
  getMatchFormatNumberByParent (params) {
    return fetch({
      url: '/dict/getMatchFormatNumberByParent',
      params: params
    })
  },
  addRule (data, options) { // 添加赛事章程
    return fetch({
      url: '/match/constitution/save',
      method: 'post',
      data,
      options
    })
  },
  getRule (params) { // 获取赛事章程内容
    return fetch({
      url: '/match/constitution/select',
      params: params
    })
  },
  editRule (data, options) { // 修改赛事章程
    return fetch({
      url: '/match/constitution/edit',
      method: 'post',
      data,
      options
    })
  },
  addMatchNotice (data, options) { // 添加赛事公告
    return fetch({
      url: '/match/info/save',
      method: 'post',
      data,
      options
    })
  },
  matchNotice (params) { // 获取赛事公告内容
    return fetch({
      url: '/match/info/select',
      params: params
    })
  },
  editMatchNotice (data, options) { // 修改赛事公告
    return fetch({
      url: '/match/info/edit',
      method: 'post',
      data,
      options
    })
  },
  delMatchNotice (data, options) { // 修改赛事公告
    return fetch({
      url: '/match/info/delete',
      method: 'post',
      data,
      options
    })
  },
  topMatchNotice (data, options) { // 赛事公共是否置顶
    return fetch({
      url: '/match/info/pull/top',
      method: 'post',
      data,
      options
    })
  },
  getEditMatchNotice (params) { // 获取需要修改的赛事公告内容
    return fetch({
      url: '/match/info/view',
      params: params
    })
  },
  getChannels (params) { // 获取渠道信息
    return fetch({
      url: '/match/run/channels',
      params: params
    })
  },
  // 下载赛程模板
  downTemplate (params) {
    return fetch({
      url: '/match/schedule/download/template',
      params: params
    })
  },
  // 获取赛事章程模板
  ruleTemplate (params) {
    return fetch({
      url: '/match/template/get',
      params: params
    })
  },
  // 判断是否有赛程
  isHaveSchedule (params) {
    return fetch({
      url: '/match/schedule/find/statusByMatchId',
      params: params
    })
  },
  // 获取赛事预览信息
  matchPreview (params) {
    return fetch({
      url: '/match/schedule/find/schedulePrevInfo',
      params: params
    })
  },
  // 获取赛程预览导航栏
  getSchedulePreview (params) {
    return fetch({
      url: '/match/schedule/select/schedulePreview',
      params: params
    }).then((res) => {
      res.data = res.data.map(item => {
        item.value = item.scheduleDate
        return item
      })
      return res
    })
  },
  // 获取赛程预览列表
  getScheduleInfo (params) {
    return fetch({
      url: '/match/schedule/find/schedulePrevInfo',
      params: params
    })
  },
  // 比赛弃权
  matchGiveup (data, options) {
    return fetch({
      url: '/match/schedule/abstained',
      method: 'post',
      data,
      options
    })
  },
  // 生成赛程
  generateSchedule (data, options) {
    return fetch({
      url: '/match/schedule/buildSchedule',
      method: 'post',
      data,
      options
    })
  },
  // 取消比赛
  matchCancel (data, options) {
    return fetch({
      url: '/match/schedule/cancel',
      method: 'post',
      data,
      options
    })
  },
  // 录入比分
  scoreWrite (data, options) {
    return fetch({
      url: '/match/schedule/scoreWrite',
      method: 'post',
      data: JSON.stringify(data),
      options
    })
  },
  // 根据赛事类型获取工作人员
  getWorker (params) {
    return fetch({
      url: '/match/schedule/editWork',
      params: params
    })
  },
  // 赛事编辑
  matchEdit (data, options) {
    return fetch({
      url: '/match/schedule/edit',
      method: 'post',
      data: JSON.stringify(data),
      options
    })
  },
  // 获取参赛球队
  getParticipant (params) {
    return fetch({
      url: '/match/sign/get/participant',
      params
    })
  },
  // 踢出球队参赛者
  batchKickOut (data) {
    return fetch({
      url: '/match/sign/batchKickOut',
      method: 'put',
      data
    })
  },
  // 查看球队参赛成员
  teamUserList (params) {
    return fetch({
      url: '/match/sign/get/teamUserList',
      params
    })
  },
  // 导出球队参赛成员
  teamUser (params) {
    return fetch({
      url: '/match/sign/export/teamUser',
      params
    })
  },
  // 获取球队成员详细资料
  teamUserInfo (params) {
    return fetch({
      url: '/match/sign/get/teamUserInfo',
      params
    })
  },
  // 提前结束报名
  termiNation (data) {
    return fetch({
      url: '/match/early/termination',
      method: 'put',
      data
    })
  },
  // 关闭赛事
  closeMatch (data) {
    return fetch({
      url: '/match/close',
      method: 'put',
      data
    })
  },
  // 个人跑步赛事组别
  groupType (params) {
    return fetch({
      url: '/match/sign/group',
      params
    })
  },
  // 个人参赛者列表
  getUsersList (params) {
    return fetch({
      url: '/match/sign/group/users',
      params
    })
  },
  // 个人参赛者详细资料
  getSingerInfo (params) {
    return fetch({
      url: '/match/sign/userinfo',
      params
    })
  },
  // 摇号操作
  lotteryList (data) {
    return fetch({
      url: '/match/sign/lottery',
      method: 'post',
      data
    })
  },
  // 赛事积分榜
  getChart (params) {
    return fetch({
      url: '/match/chart',
      params
    })
  },
  // 查询赛事榜单排名条件自定义项目数据
  getRankPriority (params) {
    return fetch({
      url: '/match/ranking/priority/select',
      params
    })
  },
  // 保存赛事榜单排名条件自定义项目数据
  saveRankPriority (data) {
    return fetch({
      url: '/match/ranking/priority/save',
      method: 'post',
      data
    })
  },
  // 获取可比赛的日期
  getRaceDate (params) {
    return fetch({
      url: '/match/schedule/init/canRaceDate',
      params
    })
  },
  // 获取赛事总比赛场次
  getMatchCount (params) {
    return fetch({
      url: '/match/get/wheel/play/count',
      params
    })
  },
  // 预览后生成赛程
  buildSchedule (data, options) {
    return fetch({
      url: '/match/schedule/buildSchedule',
      method: 'post',
      data,
      options
    })
  },
  // 生成赛程预览
  buildSchedulePrev (data, options) {
    return fetch({
      url: '/match/schedule/buildSchedulePrev',
      method: 'post',
      data: JSON.stringify(data),
      options
    })
  },
  // 直接生成赛程
  buildScheduleDirect (data, options) {
    return fetch({
      url: '/match/schedule/directBuildSchedule',
      method: 'post',
      data: JSON.stringify(data),
      options
    })
  },
  // 获取单场比赛详情
  getGameDetail (params) {
    return fetch({
      url: '/match/schedule/details',
      params
    })
  },
  // 获取种子球队参赛成员
  getSeedUser (params) {
    return fetch({
      url: '/match/draw/seedMatchUser',
      params
    })
  },
  // 设置种子球队，选手
  setSeedUser (data, options) {
    return fetch({
      method: 'PUT',
      url: '/match/draw/seedMatchUser',
      data: JSON.stringify(data),
      options
    })
  },
  // 自动生成签表
  checkTableAuto (data, options) {
    return fetch({
      method: 'POST',
      url: '/match/draw/autoBuild',
      data: data,
      options
    })
  },
  // 获取签表列表
  getDrawData (params) {
    return fetch({
      url: '/match/draw/getMatchDrawData',
      params
    })
  },
  // 手动录入签表保存草稿
  handWorkCreateDrawdDraft (data, options) {
    return fetch({
      url: '/match/draw/handWorkCreateDrawdDraft',
      method: 'POST',
      data,
      options
    })
  },
  // 手动录入签表
  handWorkCreateDraw (data, options) {
    return fetch({
      url: '/match/draw/handWorkCreateDraw',
      method: 'POST',
      data,
      options
    })
  },
  // 获取杯赛分组
  getCupGroup (params) {
    return fetch({
      url: '/match/draw/cupMatchGroup',
      params
    })
  },
  // 杯赛随机匹配
  randomMatch (data, options) {
    return fetch({
      url: '/match/draw/cupMatchGroup/random',
      method: 'POST',
      data: JSON.stringify(data),
      options
    })
  },
  // 杯赛生成分组
  CupBuildGroup (data, options) {
    return fetch({
      url: '/match/draw/cupMatchGroup/build',
      method: 'POST',
      data: JSON.stringify(data),
      options
    })
  },
  // 获取杯赛分组，日期，对阵信息
  getCupScheduleInfo (params) {
    return fetch({
      url: '/match/schedule/find/cupMatchscheduleInfo',
      params
    })
  },
  // 查看网羽乒 团体赛小比分
  getGroupScore (params) {
    return fetch({
      url: '/match/schedule/getMultilayerScoreScan',
      params
    })
  },
  // 网羽乒 团体小比分录入
  score (data, options) {
    return fetch({
      url: '/match/schedule/multilayerScoreWrite',
      method: 'POST',
      data: JSON.stringify(data),
      options
    })
  },
  // 团体网羽乒 场序
  getSequence (params) {
    return fetch({
      url: '/match/schedule/find/matchSignTeamSequence',
      params
    })
  },
  // 录入详细比分
  scoreDetail (data, options) {
    return fetch({
      url: '/match/schedule/multilayerScoreWriteAlone',
      method: 'POST',
      data: JSON.stringify(data),
      options
    })
  },
  // 查询详细比分
  getScoreDetail (params) {
    return fetch({
      url: '/match/schedule/getAloneMultilayerScoreScan',
      params
    })
  },
  // 查询杯赛 是否可以创建签表
  canCheckTable (params) {
    return fetch({
      url: '/match/schedule/allowCreateDrawResult',
      params
    })
  },
  getCupKonckoutUser (params) {
    return fetch({
      url: '/match/draw/speparatedCupOutletMember',
      params
    })
  },
  isAddMatchMember (params) { // 是否可以添加参赛者or球队
    return fetch({
      url: '/match/participant/check/participant',
      params,
      options: {errorMsg: 'none'}
    })
  },
  dynamicGetMatchList (params) { // 动态获取赛事报名字段
    return fetch({
      url: '/match/list/matchSignField',
      params
    })
  },
  saveMatchMember (data, options) { // 提交参赛者信息
    return fetch({
      url: '/match/participant/check/participant/member?matchId=' + data.matchId,
      method: 'POST',
      data: JSON.stringify(data.matchParticipantReq),
      options
    })
  },
  searchIsExistClub (data, options) { // 查询俱乐部
    return fetch({
      url: '/match/participant/list/groupInfo?matchId=' + data.matchId + '&captainIndex=' + data.captainIndex,
      method: 'POST',
      data: JSON.stringify(data.matchParticipantReq),
      options
    })
  },
  saveMultiMember (data, options) { // 批量保存参赛者成员
    return fetch({
      url: '/match/participant/save/participant/member?matchId=' + data.matchId + '&captainIndex=' + data.captainIndex,
      method: 'POST',
      data: JSON.stringify(data.matchParticipantReq),
      options
    })
  },
  checkClubname (params) { // 校验俱乐部是否存在
    return fetch({
      url: '/guest/checkNickname',
      params
    })
  },
  // 杯赛自动生成签表
  CupBuildCheckTable (data, options) {
    return fetch({
      url: '/match/draw/autoBuildSpeparatedCupDraw',
      method: 'POST',
      data,
      options
    })
  }
}
